import {
  createBrowserRouter,
  createHashRouter,
  RouterProvider,
  RouteObject,
  Navigate,
} from "react-router-dom";
import { LayoutUI } from "../components/Layout/LayoutUI";
import App from "../views/App/App";
import { list } from "../components/Layout/MenuUI";
import { AdminLayout } from "../components/AdminLayout/AdminLayout";
import { Admin } from "../views/Admin/Admin";
const menuList: RouteObject[] = list.map((i, index) => ({
  index: index == 0,
  path: i.path,
  element: i.element,
}));
const routes: RouteObject[] = [
  {
    path: "/",
    element: <Navigate to={"/home"} />,
  },
  {
    path: "/home",
    element: <LayoutUI />,
    children: menuList,
  },
  {
    path: "/admin",
    element: <AdminLayout />,
    children: [
      {
        index: true,
        element: <Admin />,
      },
    ],
  },
];
export const router = createHashRouter(routes);
